const cheerio = require("cheerio");
//安装第三方模块  cheerio
const https = require("https");
https.get("https://maoyan.com/films", (res) => {

    let str = "";
    res.on("data", (chunk) => {
        str += chunk;
    })
    res.on("end", () => {
        console.log(str);
        let $ = cheerio.load(str);
        console.log($(".newslist li").length);
        let len = $(".newslist li").length;
        for (let i = 0; i < len; i++) {
            //拿到节点里面的文本内容
            console.log($(".newslist li").eq(i).html());
        }
    })

})